# [BM50 两数之和](https://www.nowcoder.com/practice/20ef0972485e41019e39543e8e895b7f?tpId=295&tqId=40208&rp=1&difficulty=&judgeStatus=&tags=/question-ranking)
def twoSum(self, numbers, target):
    # 创建一个字典来存储值和下标
    num_dict = {}

    # 遍历数组
    for i, num in enumerate(numbers):
        complement = target - num

        # 检查差值是否已经存在于字典中
        if complement in num_dict:
            # 如果存在，返回下标，注意这里需要加1，因为题目要求下标从1开始
            return [num_dict[complement] + 1, i + 1]

        # 如果不存在，将当前数值和下标加入字典
        num_dict[num] = i

    return []